# -*- coding: utf-8 -*-

import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *


class MainWindow(QWidget):

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent=parent)
        layout = QVBoxLayout()

        self.fontBtn = QPushButton("Choose Font")
        self.fontBtn.clicked.connect(self.getFont)
        layout.addWidget(self.fontBtn)

        self.fontle = QLabel("Hello,字体示例")
        layout.addWidget(self.fontle)

        self.setLayout(layout)
        self.setWindowTitle("Font Dialog示例")

    def getFont(self):
        font, ok = QFontDialog.getFont()
        if ok:
            self.fontle.setFont(font)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    win = MainWindow()
    win.show()
    sys.exit(app.exec())